; ========================================================================
; File:NsiInstallScript.perl.morphus.0.1.0.dev.ysg.nsi
; THIS INSTALLER INSTALLS THE full source code of the morphus tool
; Author:Yordan Georgiev
; ========================================================================
!include "FileFunc.nsh"
!include "MUI2.nsh"
!include "WordFunc.nsh"
!include "Time.nsh"
!include "Sections.nsh"


!insertmacro WordFind

!insertmacro MUI_LANGUAGE "English"
!define /date MYDATE "%Y%m%d%H%M%S"
!define VERSION "0.1.0"


LangString MUI_TEXT_INSTALLING_TITLE ${LANG_ENGLISH} "morphus.0.1.0 Installation"
LangString MUI_TEXT_INSTALLING_SUBTITLE ${LANG_ENGLISH} "Installing morphus.0.1.0 perl"
LangString MUI_TEXT_FINISH_TITLE ${LANG_ENGLISH} "morphus.0.1.0 perl Ready"
LangString MUI_TEXT_FINISH_SUBTITLE ${LANG_ENGLISH} "morphus.0.1.0 perl Installed"
LangString MUI_TEXT_ABORT_TITLE ${LANG_ENGLISH} "morphus.0.1.0 perl Installation ?!"
LangString MUI_TEXT_ABORT_SUBTITLE ${LANG_ENGLISH} "morphus.0.1.0 perl Installation ?!"

XPStyle On
AutoCloseWindow false
ShowInstDetails show


Page directory
Page instfiles




;**************************************************************************************************
; BEGIN SECTION DEFINE GLOBAL VARS
Section "Setting Variables "

Var /GLOBAL ProductName
StrCpy $ProductName "morphus"

Var /GLOBAL ProductVersion
StrCpy $ProductVersion "0.1.0"

Var /GLOBAL ProductType
StrCpy $ProductType "dev"

Var /GLOBAL ProductOwner
StrCpy $ProductType "ysg"

Var /GLOBAL Dot
StrCpy $Dot "."

Var /GLOBAL ProductBaseDir
StrCpy $ProductBaseDir "E:\perl\sfw"


Var /GLOBAL EnvironmentName
StrCpy $ProductType "$ProductName$Dot$ProductVersion$Dot$ProductType$Dot$ProductOwner"


Var /GLOBAL ProductVersionDir
StrCpy $ProductVersionDir "$ProductBaseDir\$ProductName\$EnvironmentName"

SectionEnd
; END SECTION DEFINE GLOBAL VARS
;**************************************************************************************************

;**************************************************************************************************
Section
;START CREATE BACKUP OF THE EXISTING SITE IF ANY 

${time::GetLocalTime} $R0
${time::TimeString} "$R0" $0 $1 $2 $3 $4 $5
/*
0 - date
1 - month
2 - year 
3 - hour
4 - minute
5 - seconds
*/

;CREATE THE BACKUP DIRECTORY BASED ON THE TIMESTAMP
Rename $INSTDIR "$INSTDIR.$SystemVersion.${MYDATE}"
SectionEnd
; END CREATE BACKUP OF THE EXISTING SITE IF ANY 
;**************************************************************************************************



;Where to ouput the Setup.exe
OutFile "..\..\data\install\Setup.perl.morphus.0.1.0.dev.ysg.${MYDATE}.exe"

;THIS IS THE DIRECTORY WHERE WE ARE GOING TO INSTALL
InstallDir "$ProductVersionDir"


;**************************************************************************************************
Section "Unpacking" SecUnpacking
CreateDirectory $INSTDIR
SetOutPath $INSTDIR
; HERE UNZIP ACTUALLY THE FILES (ADD *.js files if needed ) 
; THE WEB SITE IS ONE DIRECTORY ABOVE
; PACK ALL THE FILES EXCEPT THOSE WITH FILE EXTENSIONS after the /x
; /x *.suo /x *.exclude /x *.ldf /x *.pl /x *.nsis  /x *.log /x *.bas /x *.reg /x *.bak 
File /r "..\..\*.*"
SectionEnd
;**************************************************************************************************

;**************************************************************************************************
Section "CreateShortcuts" CreateShortcuts
# set the installation directory as the destination for the following actions
setOutPath $DESKTOP

# create a shortcut named "bin" pointing to the version bin directory
# point the new shortcut to the bin directory
createShortCut "$DESKTOP\morphus.lnk" "$INSTDIR"

SectionEnd
;**************************************************************************************************

